#include "Platform.h"
#include "RSManager.h"
#include "Box.h"
#include "Sprite.h"
#include "GameDefine.h"
Platform::Platform(Box* box ): StaticObject(box , PLATFORM)
{
	_initpos=box->_position;
	_distance = box->_size.x;
	
}
//comment comment

Platform::~Platform(void)
{
}
void Platform::init()
{
	_box->_size =D3DXVECTOR2(64,62);
	_sprite= RSManager::getInstance()->getSprite(MOVE_PLATFORM);
	delay=0;
}

void Platform::update()
{
	delay+=GAME_TIME;
	if (delay>60)
	{
		delay =0;
		if(_box->_position.x>= _initpos.x + _distance )
			_box->_v.x= -8;
		if(_box->_position.x<=_initpos.x)
			_box->_v.x =8;
		_box->_position.x+=_box->_v.x;
	}
	
}

void Platform::render()
{
	_sprite->Render(_box->_position);
}
